import Vue from 'vue'
import Router from 'vue-router'
import ListMain from '@/pages/ListMain'
import navTop from "@/components/navTop"

Vue.use(Router)

export default new Router({
  mode: 'history', 
  routes: [
    {path:'*',redirect:'/'},
    {
      path: '/',
      name: '首页',
      components:{
        default: navTop,
        mainconten: resolve => require(['@/pages/ListMain'], resolve)
      }
    },{
      path: '/login',
      name: '登录',
      components:{
        default: navTop,
        mainconten: resolve => require(['@/pages/login'], resolve),
      },
    },{
        path: '/articleDetails',
        name: '文章详情',
        components:{
          default: navTop,
          mainconten: resolve => require(['@/pages/articleDetails'], resolve),
        }
    },{
      path: '/reg',
      name: '注册',
      components:{
        default: navTop,
        mainconten: resolve => require(['@/pages/reg'], resolve)
      }
    },{
      path: '/admin',
      name: '管理后台',
      component: resolve => require(['@/admin/adminIndex'], resolve),
      redirect: '/admin/publish',
      children: [  //这里就是二级路由的配置
        {
          path: 'publish',
          name: '发布文章',
          component: resolve => require(['@/admin/pages/publish'], resolve)
        },
        {
          path: 'management',
          name: '文章列表',
          component: resolve => require(['@/admin/pages/management'], resolve)
        },
        {
          path: 'msg',
          name: '我的消息',
          component: resolve => require(['@/admin/pages/msg'], resolve)
        },
        {
          path: 'file',
          name: '上传文件',
          component: resolve => require(['@/admin/pages/file'], resolve)
        }
      ]
    }
  ]
})
